/*
 *  Copyright 2004 Blandware (http://www.blandware.com)
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.blandware.atleap.persistence.core;

import com.blandware.atleap.common.util.PartialCollection;
import com.blandware.atleap.common.util.QueryInfo;
import com.blandware.atleap.model.core.ContentPage;
import com.blandware.atleap.model.core.Layout;
import com.blandware.atleap.persistence.exception.DeleteException;

import java.util.List;
import java.util.Date;

/**
 * <p>DAO for content page (CP)</p>
 * <p><a href="ContentPageDAO.java.html"><i>View Source</i></a></p>
 *
 * @author Sergey Zubtsovskiy <a href="mailto:sergey.zubtsovskiy@blandware.com">&lt;sergey.zubtsovskiy@blandware.com&gt;</a>
 * @version $Revision: 1.11 $ $Date: 2007/04/01 14:51:04 $
 */
public interface ContentPageDAO extends PageDAO {

	// ~ CRUD methods ================================================================

	/**
	 * Creates new content page
	 *
	 * @param contentPage Object that represents what page must be created
     * @param layout Layout on which new content page is based
	 * @return ID of created content page
	 */
	public Long createContentPage(ContentPage contentPage, Layout layout);

	/**
	 * Retrieves content page with specified ID
	 *
	 * @param contentPageId ID to search by
	 * @return Content page with specified ID or null if no page with specified ID exists in database
	 */
	public ContentPage retrieveContentPage(Long contentPageId);

	/**
	 * Updates content page
	 *
	 * @param contentPage Page to update
     * @param layout Layout on which updated content page is based
	 */
	public void updateContentPage(ContentPage contentPage, Layout layout);

	/**
	 * Deletes content page
	 *
	 * @param contentPage Page to delete
	 * @throws DeleteException if content page cannot be deleted
	 */
	public void deleteContentPage(ContentPage contentPage) throws DeleteException;

	// ~ Additional methods ================================================================

	/**
	 * Retrieves filtered/sorted collection of content pages.
	 *
	 * @param queryInfo Object that contains information about how to filter and sort data
	 * @return Collection of content pages
	 */
	public PartialCollection listContentPages(QueryInfo queryInfo);

    // ~ Finders ================================================================

	/**
	 * Finds content page by URI
	 *
	 * @param contentPageUri URI of content page to search by
	 * @return Content page or null if nothing was found
	 */
	public ContentPage findContentPageByUri(String contentPageUri);

    /**
     * Returns list of content pages, which are not published and are not
     * expired at the specified date.
     * @param date Date to compare publication and expiration date to
     * @return List of unpublished content pages
     */
    public List findUnpublishedContentPages(Date date);

    /**
     * Returns list of content pages, which are expired in comparison to
     * specified date.
     * @param date Date to compare expiration date to
     * @return List of expired content pages
     */
    public List findExpiredContentPages(Date date);
}
